﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CrmManageSystemClient.Formn
{
    public partial class Telephone : Form
    {
        public Telephone()
        {
            InitializeComponent();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            
            Data.Model.Grasp36671.btype[] btype = Data.DataGrasp.GetCustomer(textBox5.Text);
            Data.Model.Grasp36671.Dlyndx[] Dlyndx;
            //btype = Data.DataGrasp.Get_Customer(textBox5.Text);
            if (btype.Length > 1)
            {
                MessageBox.Show("包含:" + textBox5.Text + "的客户数量超过1个", "提示:" + btype.Length.ToString());
            }
            else
            {
                if (btype.Length == 1)
                {
                    textBox1.Text = btype[0].FullName;
                    textBox2.Text = btype[0].Person;
                    textBox3.Text = btype[0].Fax;
                    textBox4.Text = btype[0].Area;
                    label13.Text = btype[0].ARTotal+"元";
                    label14.Text = btype[0].APTotal + "元";
                    Dlyndx = Data.DataGrasp.Get_CustomerBills(btype[0].typeId);
                    
                    label15.Text = Dlyndx.Length.ToString() + "张";
                    //MessageBox.Show("单据总数" + Dlyndx.Length.ToString());
                    int count3 = 0;
                    listView1.Items.Clear();
                    foreach (Data.Model.Grasp36671.Dlyndx dly in Dlyndx)
                    {
                        listView1.Items.Add((count3 + 1).ToString(), 0);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].Date);
                        listView1.Items[count3].SubItems.Add(btype[0].FullName);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].Number);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].Vchcode);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].etypeid);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].DeptID);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].Total);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].InputNo);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].PostNo);
                        listView1.Items[count3].SubItems.Add(Dlyndx[count3].summary);
                        count3++;
                    }
                }
                else
                {
                    MessageBox.Show("不包含:" + textBox5.Text + "的客户", "提示:" + btype.Length.ToString());
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }


    }
}
